home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / MISC / PATHDEMO.ZIP / README.TXT < prev   
Encoding:
Text File  |  1996-09-30  |  10.1 KB  |  206 lines

  1. Readme File for PathDemo
  2. ------------------------
  3.  
  4. PathDemo was developed by Bryan Stout as a means of visually illustrating how 
  5. different pathfinding algorithms worked.  It was developed for his lecture at 
  6. the 1996 Computer Game Developers' Conference, and has since been enhanced.  It was used as the source of the illustrations for his Game 
  7. Developer Magazine article "Smart Moves: Intelligent Path-Finding," and is 
  8. available here to download from GDM's website.  This file explains the basics 
  9. of how PathDemo and its components work, there having been no help file 
  10. developed for it yet.  
  11.  
  12. PathDemo was developed in Delphi 2.0, and so needs Win95 or Windows NT to run.
  13.  
  14. This version of PathDemo may be distributed freely, as long as this unaltered 
  15. ReadMe file accompanies it.
  16.  
  17.  
  18. Overview
  19. --------
  20.  
  21. In PathDemo, one can edit a square grid map, select a search algorithm, and 
  22. observe how the search functions in the map.  Functions available include:
  23. - Map Edit: lay out terrain of varying cost, assign start/goal nodes.
  24. - Search Control: start, pause, continue, clear search; change display speed; 
  25.    zoom in or out.
  26. - Algorithm Selection: choose search algorithm, assign appropriate parameters.
  27. - Heuristic Selection: assign heuristic weight, choose distance approximation 
  28.    function.
  29.  
  30.  
  31. Map Editor Panel and Map Display
  32. ---------------------------------
  33.  
  34. The Map Display shows a square grid which is the map used for searching paths.  
  35. The map begins at the largest magnification, and all the squares begin with 
  36. clear terrain.  The grid's full size is 40 columns by 32 rows.
  37.  
  38. The Map Editor panel contains a set of radio buttons showing the different 
  39. terrains that can be assigned to the map tiles -- with their relative costs -- 
  40. including blocked terrain, and the start and goal nodes.
  41.  
  42. - To show different parts of the map grid, use the scroll bars beside the grid.
  43. - To zoom the map grid out or in, use the "Map Size" track bar in Search 
  44. Control panel in the upper right corner.
  45. - To place a start node in the map, click the Start radio button, and then 
  46. click on any square in the map.  Clicking in other squares will move the start 
  47. to that location -- there can be only one start square.  The Goal node 
  48. placement works in exactly the same way.  The location of the start and goal 
  49. nodes has no effect on the terrain cost, and vice versa.
  50. - To change the terrain cost of map squares, click on the terrain you want to
  51. paint on the map.  Every individual square you click on will change to that 
  52. terrain.  Clicking and dragging will paint every square in the rectangle which 
  53. has the the click and current squares as corners.  To correct mistakes, you 
  54. will have to paint them back to the way you want them.   
  55.  
  56.  
  57. Search Algorithm Panel
  58. ----------------------
  59.  
  60. In this panel, you can select the search algorithm, and alter parameters 
  61. affecting them.  These are the algorithm choices available:
  62.  
  63. First, there are unplanned searches, which simply head towards the goal, and
  64. deal with obstacles as they come up (for details on the algorithms, see the 
  65. article "Smart Moves"):
  66.  
  67. - Random Bounce. If an obstacle is detected, head in a random direction for 
  68. one square, and try again.
  69. - Simple Trace. Trace around obstacles until one is heading in the same 
  70. direction again.
  71. - Robust Trace. Compute the line segment joining the blocking spot and the 
  72. goal.  Trace until that line is crossed again.
  73.  
  74. All the other searches plan the whole route ahead.  Some of them use a 
  75. recursive stack to keep track of the search's progress:
  76.  
  77. - Depth-First Search (DFS).  This simply tries all paths out to a given depth.
  78. - Iterative-Deepening Depth-First Search (IDDF).  This does the DFS search 
  79. at increasing depths, until a path is found. 
  80. - Iterative-Deepening A-Star Search (IDA*).  This is like IDDF, but it keeps 
  81. track of the cost of the path from home, and estimates the distance to the 
  82. goal.  If their sum is too great, the search cuts off (but this cutoff depth
  83. keeps increasing until the path is found).
  84.  
  85. The remaining searches keep a couple of lists of the squares visited -- Open, 
  86. for those not examined yet, and Closed, for those which have been.  When each 
  87. node is examined, its neighbors are put on Open: 
  88.  
  89. - Breadth-First Search.  Open is just a FIFO queue, so all the nodes are 
  90. expanded in the order they are place on Open.
  91. - Dijkstra's Algorithm.  Similar to breadth-first, but it keeps track of the 
  92. distance from the goal of all the squares.  Open is kept sorted in order by 
  93. this distance, and nodes can be re-ordered in the lists (and even moved from 
  94. Closed back to Open) if a shorter path to the square is found.
  95. - Best-First Search.  This sorts nodes in Open according to the shortest 
  96. estimated distance to the goal.  This makes the search very fast, but it 
  97. ignores the cost of terrain.
  98. - A-Star Search (A*).  The nodes in Open are sorted by the sum (f) of the 
  99. distance from start (g) and the estimate to the goal (h).  All around, the 
  100. most robust of these search algorithms.
  101.  
  102.  
  103. - To view the algorithm choices, click on the up or down arrows at the right 
  104. end of the list box at the top of the panel.
  105. - To select an algorithm, click on the choise that is visible; the selected 
  106. choice is colored blue.  The seach won't run if an algorithm is not chosen.
  107. - To specify a bi-directional search for Open list-based searches, click the
  108. "Bidirectional Search" check box.  Note: this does not yet work perfectly, as 
  109. it takes the first solution found which joins both ends, rather than waiting 
  110. for the best one.
  111. The remaining controls affect stack-based searches (DFS, IDDF, IDA*):
  112. - To save, at each square, the shortest path discovered to that square, click 
  113. the "Save Min Path Length" check box.  With this unchecked, the stack-based 
  114. searches are horribly inefficient, retreading old ground frequently (try it!).
  115. - To have the search always aim first towards the goal, check the "Aim to Goal
  116. First" check box.  Also a big help.
  117. - To set the depth for DFS, click on the arrows of the "Search Depth" spin 
  118. control, or enter a value into the box directly.
  119.  
  120.  
  121. Heuristic Estimate Panel
  122. ------------------------
  123.  
  124. The controls here control how the Best-First and A* searches make estimates
  125. of the distance remaining to the goal.  This estimate can vary depending on 
  126. one's application; PathDemo always computes it by multiplying a constant weight 
  127. times the estimated true distance.  Both of these factors can be altered.
  128.  
  129. - To change the constant weight, move the slider in the Heuristic Weight track
  130. bar.  Note that if the terrain is all clear, '1' is the correct value.  If 
  131. there is much terrain of higher cost, other values may give a better 
  132. approximation.  A '0' yields the same as Dijkstra's search; a value higher than 
  133. all the terrain cost yields the same as Best-first search.
  134. - To choose a different distance function, view the different entries in the 
  135. Distance Function list box, and click the one desired.  
  136.  
  137. The different distance functions are:
  138. - The maximum of the differences in the X and Y coordinates (max(dx,dy)).
  139. - The Euclidean distance (square root of sum of squares of dx, dy).
  140. - The diagonal shortcut.  A diagonal route is followed until one is directly 
  141. up, down, or across from the goal, and an orthogonal distance is used for the 
  142. remainder of the way.  PathDemo uses 1.4 as an estimate of the diagonal 
  143. distance.
  144. - The Manhattan distance (dx + dy).
  145. If the start were at [1,1], and the goal at [5,4], then dx=4, dy=3, and the 
  146. different distance functions would give us 4, 5, 6.2, and 7 respectively.  In 
  147. PathDemo's map (squares, with diagonal moves allowed), the diagonal shortcut 
  148. gives the true distance between two squares as the crow flies; the first 
  149. two give underestimates, the last one an overestimate.
  150.  
  151.  
  152. Search Control Panel
  153. --------------------
  154.  
  155. This panel has controls over starting, stopping, and clearing the search, and 
  156. over the search speed and map size.
  157.  
  158. When the search runs, its visual display depends on the type of search being
  159. done:
  160. - Unplanned searches show a blue diamond moving across the map, leaving a blue
  161. trail behind it showing its past moves.
  162. - Stack-based searches show a red line for the path being considered, which 
  163. snakes in and out as different routes are considered.
  164. - List-based searches outline the squares in different colors according to 
  165. their situation: 
  166.    - green for nodes on the Open list 
  167.    - red for the current node (the one just popped from Open)
  168.    - blue for nodes on the Closed list
  169. A dark red line connects each square with its parent node.
  170. - For both list-based and stack-based searches, when a final path is found, its 
  171. squares are outlined in bright green, and its path is a bright red line of 
  172. double thickness.
  173.  
  174. - To start the search, click on the "Go" button.  This will also disable most 
  175. of the other controls, and change the button's label to "Pause".
  176. - To pause the search temporarily, press the "Pause" button.  The changes the 
  177. label to "Continue", and  enables most of the controls, so one can alter the 
  178. map terrain and heuristic estimate.  The start and goal nodes, and the search 
  179. algorithm, cannot be altered mid-stream.
  180. - To continue the search after pausing it, click the "Continue" button, which
  181. has the same effect as clicking "Go". 
  182. - To clear all the search, click "Clear".  This is only possible when the 
  183. search is paused, or after the search has finished.  Clearing clears out all 
  184. the search information and enables all the controls, but leaves the map and 
  185. the control values unaltered.
  186. - To change the speed of the search, move the slider in the Search Speed track 
  187. bar.  The track bar adjusts the speed exponentially, so the speed can range 
  188. from excruciatingly slow to almost instantaneous.
  189.  
  190.  
  191. Afterword
  192. ---------
  193.  
  194. There are several more features I'd like to add to PathDemo.  I am interested 
  195. in your feedback about it, to know whether it has helped you, and what 
  196. improvements you'd like to see.  
  197.  
  198. Comments can be directed to gdmag@mfi.com, who will forward them to me.
  199.  
  200.  
  201. Regards,
  202. Bryan Stout
  203.  
  204. ----+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
  205.  
  206.